# books/serializer.py
from rest_framework import serializers

from hello.models import UserInfo, Drug, Manufacturer, Stock, Buyer, Sales, Supply, DrugTreatment


class UserInfoSerializer(serializers.ModelSerializer):
    class Meta:
        model = UserInfo
        fields = ('id', 'name', 'pwd', 'role')


class DrugSerializer(serializers.ModelSerializer):
    class Meta:
        model = Drug
        fields = ('id', 'drug_name', 'drug_inprice', 'drug_outprice', 'drug_type')


class ManufacturerSerializer(serializers.ModelSerializer):
    class Meta:
        model = Manufacturer
        fields = ('id', 'name', 'phone', 'address')


class StockSerializer(serializers.ModelSerializer):
    class Meta:
        model = Stock
        fields = ('id', 'stock_quantity', 'address', 'drug_name', 'stock_warning')


class BuyerSerializer(serializers.ModelSerializer):
    class Meta:
        model = Buyer
        fields = ('id', 'name', 'gender', 'phone')


class SalesSerializer(serializers.ModelSerializer):
    class Meta:
        model = Sales
        fields = ('id', 'drug_name', 'sale_date', 'sale_discount', 'quantity', 'total_amount', 'buyer')


class SupplySerializer(serializers.ModelSerializer):
    class Meta:
        model = Supply
        fields = ('id', 'drug_name', 'manufacturer_name', 'supply_date', 'quantity', 'total_amount')


class DrugTreatmentSerializer(serializers.ModelSerializer):
    class Meta:
        model = DrugTreatment
        fields = (
            'id', 'drug_name', 'drug_quantity', 'treatment_date', 'treatment_method', 'treatment_reseon', 'treated_by')
